﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;

namespace BCDEditUI
{
    public partial class Form1 : Form
    {
        public string FileName
        {
            get
            {
                return tbVhd.Text;
            }

            set
            {
                tbVhd.Text = value;
            }
        }

        public string Output
        {
            get
            {
                return tbOutput.Text;
            }

            set
            {
                tbOutput.Text = value;
            }
        }

        public Form1(string[] args)
        {
            InitializeComponent();
            if (args.Length > 0)
            {
                string arg = args[0].ToLower();
                if (arg == "-addbootable")
                {
                    tabs.SelectedIndex = 0;
                    ucAddBootableVhd1.SetArgs(args);
                }
                else
                if (arg == "-creatediff")
                {
                    tabs.SelectedIndex = 1;
                    ucCreateVhd1.SetArgs(args);
                }
                
            }
        }

        private void btnSelectVhd_Click(object sender, EventArgs e)
        {
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                tbVhd.Text = ofd.FileName;
                ucAddBootableVhd1.VhdSelected(ofd.FileName);
            }
        }

        private void btnStartMsConfig_Click(object sender, EventArgs e)
        {
            Process.Start("MSConfig");
        }

        private void btnAddMenu_Click(object sender, EventArgs e)
        {
            //string programName = Path.GetFileName(Application.ExecutablePath);
            //string folder = Path.GetFullPath(Application.ExecutablePath);
            WindowsContextMenu.AddEntries(new string[] { ".vhd" }, "Add bootable VHD", Application.ExecutablePath, @"-AddBootable ""%1""", "Bootable");
            WindowsContextMenu.AddEntries(new string[] { ".vhd" }, "Create differencing VHD", Application.ExecutablePath, @"-CreateDiff ""%1""", "CreateDiff");

            Output = "Entries added.";
        }
    }
}
